import request from "@/utils/request";
import type { categoryResonseData, attr } from "./type";
enum API {
  // 获取一级分类的接口地址
  C1_URL = "/admin/product/getCategory1",
  // 获取二级分类的接口地址
  C2_URL = "/admin/product/getCategory2/",
  // 获取三级分类的接口地址
  C3_URL = "/admin/product/getCategory3/",
  // 获取商品列表的接口地址
  ATTRINFOLIST_URL = "/admin/product/attrInfoList/",
  // 添加或修改已有属性的接口地址
  ADDORUPDATEATTR_URL = "/admin/product/saveAttrInfo",
  // 删除已有属性的接口地址
  DELETEATTR_URL = "/admin/product/deleteAttr/",
}
export const reqGetC1 = () => request.get<any, categoryResonseData>(API.C1_URL);
export const reqGetC2 = (id: number | string) =>
  request.get<any, categoryResonseData>(API.C2_URL + id);
export const reqGetC3 = (id: number | string) =>
  request.get<any, categoryResonseData>(API.C3_URL + id);
export const reqGetAttrInfoList = (
  category1Id: number,
  category2Id: number,
  category3Id: number
) =>
  request.get<any, any>(
    API.ATTRINFOLIST_URL + `${category1Id}/${category2Id}/${category3Id}`
  );
export const reqAddOrUpdateAttr = (data: attr) =>
  request.post<any, any>(API.ADDORUPDATEATTR_URL, data);
export const reqDeleteAttr = (id: number) =>
  request.delete(API.DELETEATTR_URL + id);
